package com.an.pay.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

@Configuration
@EnableSwagger2WebMvc
public class SwaggerConfig {

    @Bean
    public Docket wxApiConfig() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("微信api")
                .apiInfo(wxApiInfo())
                .select()
                .paths(PathSelectors.regex("/api/wx-pay/.*"))
                .build();

    }

    @Bean
    public Docket aliPayConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("支付宝api")
                .apiInfo(aliApiInfo())
                .select()
                .paths(PathSelectors.regex("/api/ali-pay/.*"))
                .build();
    }

    private ApiInfo wxApiInfo(){
        return new ApiInfoBuilder()
                .title("微信api文档")
                .description("文档提供了微信支付的功能接口")
                .version("1.0")
                .contact("2910340901@qq.com")
                .build();
    }

    private ApiInfo aliApiInfo(){
        return new ApiInfoBuilder()
                .title("支付宝api文档")
                .description("文档提供了支付宝支付的功能接口")
                .version("1.0")
                .contact("2910340901@qq.com")
                .build();
    }
}
